package com.ruoyi.system.service.impl;
/*
 * @ClassName ApproveMenuServiceImpl
 * @Description //TODO
 * @Author Administrator
 * @Date 2024/4/11 16:00
 **/

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.enums.ApprovalMenu;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ActivityLeave;
import com.ruoyi.system.domain.ActivitySupplementSignature;
import com.ruoyi.system.domain.MeetingLeave;
import com.ruoyi.system.domain.MeetingSupplementSignature;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ApproveMenuServiceImpl implements ApproveMenuService {

    @Autowired
    private IMeetingLeaveService meetingLeaveService;
    @Autowired
    private IMeetingSupplementSignatureService meetingSupplementSignatureService;
    @Autowired
    private IActivityLeaveService activityLeaveService;
    @Autowired
    private IActivitySupplementSignatureService activitySupplementSignatureService;

    /**
     * 添加审批列表数据
     * menuMark 菜单标志
     * formData 表单数据
     */
    @Override
    public String insertApproveMenuData(String menuMark, Map formData){
        String id = "";
        if(menuMark.equals(ApprovalMenu.MEET_LEAVE.getMenuMark())){
            //TODO 解析表单数据
            MeetingLeave meetingLeave = new MeetingLeave();
            meetingLeaveService.insertMeetingLeave(meetingLeave);
            id = meetingLeave.getId();
        }else if(menuMark.equals(ApprovalMenu.MEET_SIGNATURE.getMenuMark())){
            MeetingSupplementSignature meetingSupplementSignature = new MeetingSupplementSignature();
            meetingSupplementSignatureService.insertMeetingSupplementSignature(meetingSupplementSignature);
            id = meetingSupplementSignature.getId();
        }else if(menuMark.equals(ApprovalMenu.ACTIVITY_LEAVE.getMenuMark())){
            ActivityLeave activityLeave = new ActivityLeave();
            activityLeaveService.insertActivityLeave(activityLeave);
            id =  activityLeave.getId();
        }else if(menuMark.equals(ApprovalMenu.ACTIVITY_LEAVE.getMenuMark())){
            ActivitySupplementSignature activitySupplementSignature = new ActivitySupplementSignature();
            activitySupplementSignatureService.insertActivitySupplementSignature(activitySupplementSignature);
            id =  activitySupplementSignature.getId();
        }
        return id;
    }

    /**
     * 修改审批状态
     * menuMark 菜单标志
     * status 状态
     */
    @Override
    public void updateApproveMenuDataStatus(String menuMark, String id, String status){
        if(menuMark.equals(ApprovalMenu.MEET_LEAVE.getMenuMark())){
            //TODO 解析表单数据
            MeetingLeave meetingLeave = new MeetingLeave();
            meetingLeave.setId(id);
            meetingLeave.setStatus(status);
            meetingLeaveService.updateMeetingLeave(meetingLeave);
        }else if(menuMark.equals(ApprovalMenu.MEET_SIGNATURE.getMenuMark())){
            MeetingSupplementSignature meetingSupplementSignature = new MeetingSupplementSignature();
            meetingSupplementSignature.setId(id);
            meetingSupplementSignature.setStatus(status);
            meetingSupplementSignatureService.updateMeetingSupplementSignature(meetingSupplementSignature);
        }else if(menuMark.equals(ApprovalMenu.ACTIVITY_LEAVE.getMenuMark())){
            ActivityLeave activityLeave = new ActivityLeave();
            activityLeave.setId(id);
            activityLeave.setStatus(status);
            activityLeaveService.updateActivityLeave(activityLeave);
        }else if(menuMark.equals(ApprovalMenu.ACTIVITY_LEAVE.getMenuMark())){
            ActivitySupplementSignature activitySupplementSignature = new ActivitySupplementSignature();
            activitySupplementSignature.setId(id);
            activitySupplementSignature.setStatus(status);
            activitySupplementSignatureService.updateActivitySupplementSignature(activitySupplementSignature);
        }
    }


}
